package com.mychat.entity.po;

import java.io.Serializable;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mychat.entity.Constants;
import org.springframework.format.annotation.DateTimeFormat;
import com.mychat.enums.DateTimePatternEnum;
import com.mychat.utils.DateUtils;

/**
 * @Description:用户信息
 * @auther:YYT
 * @date:2025/03/02
 */
public class UserInfo implements Serializable {
	/**
	 * 用户ID
	 */
	private String userId;

	/**
	 * 邮箱
	 */
	private String email;

	/**
	 * 昵称
	 */
	private String nickName;

	/**
	 * 0: 直接加，1:需要同意
	 */
	private Integer joinType;

	/**
	 * 0: 女，1: 男
	 */
	private Integer sex;

	/**
	 * 密码
	 */
	private String password;

	/**
	 * 个性签名
	 */
	private String personalSignature;

	/**
	 * 状态
	 */
	private Integer status;

	/**
	 * 创建时间
	 */
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date createTime;

	/**
	 * 最后登录时间
	 */
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date lastLoginTime;

	/**
	 * 最后离开时间
	 */
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date lastOffTime;

	/**
	 * 地区名称
	 */
	private String areaName;

	/**
	 * 地区编号
	 */
	private String areaCode;

	private Integer onlineType;

	public Integer getOnlineType() {
		if(lastLoginTime != null && lastLoginTime.getTime() > lastOffTime.getTime()) {
			return Constants.ONE;
		} else {
			return Constants.ZERO;
		}
	}

	public void setOnlineType(Integer onlineType) {
		this.onlineType = onlineType;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getNickName() {
		return nickName;
	}

	public void setNickName(String nickName) {
		this.nickName = nickName;
	}

	public Integer getJoinType() {
		return joinType;
	}

	public void setJoinType(Integer joinType) {
		this.joinType = joinType;
	}

	public Integer getSex() {
		return sex;
	}

	public void setSex(Integer sex) {
		this.sex = sex;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getPersonalSignature() {
		return personalSignature;
	}

	public void setPersonalSignature(String personalSignature) {
		this.personalSignature = personalSignature;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getLastLoginTime() {
		return lastLoginTime;
	}

	public void setLastLoginTime(Date lastLoginTime) {
		this.lastLoginTime = lastLoginTime;
	}

	public Date getLastOffTime() {
		return lastOffTime;
	}

	public void setLastOffTime(Date lastOffTime) {
		this.lastOffTime = lastOffTime;
	}

	public String getAreaName() {
		return areaName;
	}

	public void setAreaName(String areaName) {
		this.areaName = areaName;
	}

	public String getAreaCode() {
		return areaCode;
	}

	public void setAreaCode(String areaCode) {
		this.areaCode = areaCode;
	}

	@Override
	public String toString() {
		return "用户ID:" + (userId == null ? "空" : userId) + ",邮箱:" + (email == null ? "空" : email) + ",昵称:" + (nickName == null ? "空" : nickName) + ",0: 直接加，1:需要同意:" + (joinType == null ? "空" : joinType) + ",0: 女，1: 男:" + (sex == null ? "空" : sex) + ",密码:" + (password == null ? "空" : password) + ",个性签名:" + (personalSignature == null ? "空" : personalSignature) + ",状态:" + (status == null ? "空" : status) + ",创建时间:" + (createTime == null ? "空" : DateUtils.format(createTime, DateTimePatternEnum.YYYY_MM_DD_HH_MM_SS.getPattern())) + ",最后登录时间:" + (lastLoginTime == null ? "空" : DateUtils.format(lastLoginTime, DateTimePatternEnum.YYYY_MM_DD_HH_MM_SS.getPattern())) + ",最后离开时间:" + (lastOffTime == null ? "空" : DateUtils.format(lastOffTime, DateTimePatternEnum.YYYY_MM_DD_HH_MM_SS.getPattern())) + ",地区名称:" + (areaName == null ? "空" : areaName) + ",地区编号:" + (areaCode == null ? "空" : areaCode);
	}
}